package com.sean.dto;

import java.io.Serializable;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "USER_ROLE", uniqueConstraints = { @UniqueConstraint(columnNames = {
		"LLID", "HR_ID", "ROLE_NAME" }) })
public class UserRole implements Serializable {

	private static final long serialVersionUID = 2167963483819015300L;
	@EmbeddedId
	private UserRolePK userrolepk;

	@ManyToOne
	@JoinColumn(name = "HR_ID")
	private Employee adminemployee;

	public UserRolePK getUserrolepk() {
		return userrolepk;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((userrolepk == null) ? 0 : userrolepk.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserRole other = (UserRole) obj;
		if (userrolepk == null) {
			if (other.userrolepk != null)
				return false;
		} else if (!userrolepk.equals(other.userrolepk))
			return false;
		return true;
	}

	public Employee getAdminemployee() {
		return adminemployee;
	}

	public void setAdminemployee(Employee adminemployee) {
		this.adminemployee = adminemployee;
	}

	public void setUserrolepk(UserRolePK userrolepk) {
		this.userrolepk = userrolepk;
	}

}
